<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设置banner</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui.css" media="all">
  <style>
    .layui-table-tool {
      min-height: unset;
    }
    .layui-table-view .layui-table[lay-size="sm"] .layui-table-cell {
      height: 25px;
      line-height: 25px;
    }
  </style>
<body>


<div class="layui-form" lay-filter="layuiadmin-form-role" id="layuiadmin-form-role" style="padding: 20px 30px 0 0;">

  <div class="layui-form-item">
    <label class="layui-form-label">代理商</label>
    <div class="layui-input-block" id="quick_list">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">人群类型</label>
    <div class="layui-input-block">
      <input type="radio" name="type" value="0" title="审核人员" >
      <input type="radio" name="type" value="1" title="广告线上" checked>
      <input type="radio" name="type" value="2" title="屏蔽地区">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">展示位置</label>
    <div class="layui-input-block">
      <select name="seat" lay-verify="required" lay-search>
        <option value="">请选择</option>
        <option value="0">首页</option>
        <option value="1">男频首页</option>
        <option value="2">女频首页</option>
        <option value="3">书架页</option>
      </select>
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">横图</label>
    <div class="layui-input-block">
      <div class="layui-upload-drag" id="uploadBanner" style="width: 300px;">
        <div id="cover_head">
        <i class="layui-icon"></i>
        <p>点击上传，或将文件拖拽到此处</p>
      </div>
      <div class="layui-hide" id="uploadDemoView">
        <hr>
        <img src="" alt="上传成功后渲染" style="max-width: 279px;">
        <input type="hidden" name="banner" value="">
      </div>
    </div>
  </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">充值活动</label>
    <div class="layui-input-block">
      <select name="activity_id" lay-search>
        <option value="">请选择</option>
        {foreach $allActivity as $vo}
        <option value="{$vo.id}">{$vo.title}</option>
        {/foreach}
      </select>
    </div>
  </div>

  <div class="layui-form-item layui-hide">
    <button class="layui-btn" lay-submit lay-filter="LAY-user-role-submit" id="LAY-user-role-submit">提交</button>
  </div>
</div>


<script src="/static/layuiadmin/layui/layui.js"></script>
<script>
  layui.config({
    base: '/static/layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index',
    xmSelect: 'xmSelect/xm-select'
  }).use(['index', 'form','upload','table','xmSelect'], function(){
    var $ = layui.$
            ,admin = layui.admin
            ,form = layui.form
            ,upload = layui.upload
            ,table = layui.table
            ,xmSelect = layui.xmSelect;

    var jdb_xm = xmSelect.render({
      el: '#quick_list',
      name:'agent_id',
      filterable: true,
      data: {$agent_list|raw}
  });

    upload.render({
      elem: '#uploadBanner'
      ,accept:'images'
      ,acceptMime: 'image/jpeg, image/png'
      ,url: '/tool/uploadPic?dirName=banner'
      ,done: function(res){
        if (res.code === 1){
          layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.data.picUrl);
          layui.$('#uploadDemoView').find('input').val(res.data.filePath);
          layui.$('#cover_head').addClass('layui-hide');
          console.log(res)
        }else {
          layer.msg(res.msg);
        }
      }
    });

    table.init('parse-table-demo', { //转化静态表格
      //height: 'full-500'
      toolbar: '#addNovel' //开启头部工具栏，并为其绑定左侧模板
      , defaultToolbar: false
      , size: 'sm' //小尺寸的表格
    });

    //监听行工具事件
    table.on('tool(parse-table-demo)', function (obj) {
      var data = obj.data;
      if (obj.event === 'del') {
        document.getElementById("novel_" + data.id).remove();
        obj.del();
      }
    });


  });
</script>
</body>
</html>
